﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
//#include <osgQOpenGL/osgQOpenGLWidget>
#include "osgqt.h"
#include "elementreader.h"
#include <QPushButton>
#include <QDoubleSpinBox>


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
typedef struct jogplat
{
    QPushButton* Leftbt=nullptr;
    QDoubleSpinBox* spbox=nullptr;
    QPushButton* Righbt=nullptr;
    osg::Matrix matrix;
    osg::ref_ptr<osg::MatrixTransform> trans;
    osg::ref_ptr<osg::Node> coord;
    osg::ref_ptr<osg::Group> model;
};
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_pushButton_clicked();
    void initosg();
    void on_checkBox_stateChanged(int arg1);
    void on_pushButton_2_clicked();
    void jointdatachange();
    void jogjoint(double value);
    void showcoord(int isshow);

private:
    QString findKey(QString key, QMap<QString, JOINT> map);
    void viewupdate();

private:
    Ui::MainWindow *ui;
    osgQOpenGLWidget *pOsgW;
    QMap<QString,osg::ref_ptr<osg::Node>> nodemap;
    elementReader* reader;
    QMap<QDoubleSpinBox*,osg::ref_ptr<osg::MatrixTransform> > osgnodelist;
    QMap<QString,jogplat> jogmap;
    QVector<double> jointdata;
};
#endif // MAINWINDOW_H
